from __future__ import unicode_literals
from django.shortcuts import render
from django.http import HttpResponse
from . import ana
# Create your views here.
import time

REMOTE_HOST = 'https://pyecharts.github.io/assets/js'


def index(request):
    chipo = ana.ChipotleNan()
    # 餐厅的销售流水总额
    six = chipo.money_sum()
    # 销售个数最多的商品
    seven = chipo.get_num_max()
    # 销售金额最多的商品
    eight = chipo.get_money_max()
    # ChickenBowl最多的配料
    nine = chipo.get_chicken_bowl()
    context = {}
    # return HttpResponse('OK')
    return render(request,'c2/form.html',context={'six':six,'seven':seven,'eight':eight,'nine':nine})
# 生成每种商品的销售次数的bar图像
def index1(request):
    chipo = ana.ChipotleNan()
    bar = chipo.how_many_num()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)
# 生成每种商品的销售金额的bar图像
def index2(request):
    chipo = ana.ChipotleNan()
    bar = chipo.how_much_money()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)

def index3(request):
    chipo = ana.ChipotleNan()
    bar = chipo.sell_one_shop_rate()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)
def index4(request):
    chipo = ana.ChipotleNan()
    pie = chipo.one_money()
    context = dict(
        myechart=pie.render_embed(),
        host=REMOTE_HOST,
        script_list=pie.get_js_dependencies()
    )
    return render(request, 'index.html', context)
def index5(request):
    chipo = ana.ChipotleNan()
    bar = chipo.one_shop_num_to_rate()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)
